package com.example.web.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.example.demo.dto.ResultDTO;

@RestControllerAdvice
public class MyExceptionAdvice {


    @ExceptionHandler(LoginException.class)
    public ResultDTO exceptionHandler(LoginException e){
        return new ResultDTO(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResultDTO exceptionHandler(Exception e){
        return new ResultDTO(1002,e.getMessage());
    }
}
